#ifndef __COMPONENT_FINDER_H__
#define __COMPONENT_FINDER_H__

#include <boost/smart_ptr.hpp>
#include <vector>
#include <map>
#include <stack>

namespace cshotel {
    class ImageSet;
    class InputImage;
    
    class ComponentFinder {
    public:
        ComponentFinder(boost::shared_ptr<ImageSet> imgs);
        boost::shared_ptr<std::vector<boost::shared_ptr<ImageSet> > > findComponents();
        
    private:
        boost::shared_ptr<ImageSet> imageSet;
       
        int hittingTimeCounter;
        std::map<boost::shared_ptr<InputImage>, int> hittingTime;
        std::map<boost::shared_ptr<InputImage>, int> lowLink;
        std::map<boost::shared_ptr<InputImage>, bool> inStack;
        std::stack<boost::shared_ptr<InputImage> > dfsStack;
        boost::shared_ptr<std::vector<boost::shared_ptr<ImageSet> > > components;
        
        void dfs(boost::shared_ptr<InputImage> currentImage);
    };
}

#endif
